package com.lh.filter.method2;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.Filter;

/**
 * 过滤器手动实现方法二的配置类
 *
 * @Author LuoHang
 * @Date 2022-05-10 19:07
 **/
@Configuration
public class MyFilterConfig {
    /**
     * 注册过滤器
     * @return 过滤器注册对象
     */
    @Bean
    public FilterRegistrationBean<Filter> filterRegistrationBean(){
        FilterRegistrationBean<Filter> bean =  new FilterRegistrationBean<>();
        bean.setFilter(new MyFilter02());
        bean.addUrlPatterns("/myServlet02","/myServlet03");
        return bean;
    }
}
